import requests
# tencent/Hunyuan-MT-7B

url = "https://api.siliconflow.cn/v1/chat/completions"
headers = {
    "Authorization": "Bearer sk-qstxvnwncinymkyuxnsyxvwujurekrazkepzvbzwzhqmkdtn",
    "Content-Type": "application/json"
}
payload = {
    "model": "tencent/Hunyuan-MT-7B",
    "messages": [
        {
            "role": "user",
            "content": "把用户输入的文本翻译成英文，不要额外解释和回应。"
        },
        {
            "role": "user",
            "content": "你是谁？"
        }
    ],
        "max_tokens": 8192,  # 按需添加
        "temperature": 0.7, # 按需添加
        "top_k": 20,        # 按需添加
        "top_p": 0.6,       # 按需添加
        "frequency_penalty": 0 # 按需添加
}

response = requests.post(url, headers=headers, json=payload)
import json
answer = response.text
answer = json.loads(response.text)
context = answer['choices'][0]['message']['content']
print(context)